﻿namespace DAL.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class ModifyEmployeeAddInOut : DbMigration
    {
        public override void Up()
        {
            DropForeignKey("dbo.yqzs", "YqzsId", "dbo.employee");
            CreateTable(
                "dbo.inout",
                c => new
                    {
                        InOutId = c.Guid(nullable: false),
                        CreateTime = c.DateTime(nullable: false),
                        InOutType = c.String(maxLength: 10),
                        EmployeeId = c.Guid(nullable: false),
                    })
                .PrimaryKey(t => t.InOutId)
                .ForeignKey("dbo.employee", t => t.EmployeeId, cascadeDelete: true)
                .Index(t => t.EmployeeId);
            
            AddColumn("dbo.employee", "EmployeeStatus", c => c.String());
            Sql("update employee set EmployeeStatus = N'已退场'");
            Sql("delete from yqzs");
            AddForeignKey("dbo.yqzs", "YqzsId", "dbo.inout", "InOutId", cascadeDelete: true);
        }
        
        public override void Down()
        {
            DropForeignKey("dbo.inout", "EmployeeId", "dbo.employee");
            DropForeignKey("dbo.yqzs", "YqzsId", "dbo.inout");
            DropIndex("dbo.inout", new[] { "EmployeeId" });
            DropColumn("dbo.employee", "EmployeeStatus");
            DropTable("dbo.inout");
            AddForeignKey("dbo.yqzs", "YqzsId", "dbo.employee", "EmployeeId", cascadeDelete: true);
        }
    }
}
